#! /bin/sh
# $1 == plugin name
# $2 == things to get the cflags of
# $3 == things to get the lib cflags of
# $4 == Additional gcc args
function build_plugin {
	echo "building plugin $1"
	gcc -c plugins/${1}.c `pkg-config --cflags $2` -I./include -fPIC -fno-strict-aliasing -g -Wall $4
	gcc -shared -o lib${1}.so ${1}.o `pkg-config --libs -cflags $3`
}

# List plugins that only need libdecoration in both cases
STD_PLUGINS="input resize stdbutton gtkTA"
	
gcc src/main.c src/plugin.c src/privates.c src/functions.c src/decor.c src/timeout.c -o jasper `pkg-config --libs --cflags libdecoration` -I./include -DHOME_PLUGINDIR='".compiz/jasper"' -DPLUGINDIR='"."' -g -fno-strict-aliasing -rdynamic -Wall

gcc -c plugins/core.c -I./include -fPIC -fno-strict-aliasing -g `pkg-config --cflags libdecoration`
gcc -shared -o libcore.so core.o `pkg-config --libs --cflags libdecoration`

for stdplugin in $STD_PLUGINS; do
	build_plugin $stdplugin libdecoration libdecoration
done

build_plugin buttons "libdecoration libxml-2.0" "libdecoration libxml-2.0" -Wno-pointer-sign 
build_plugin shape "libdecoration cairo-xlib" "libdecoration cairo-xlib xext"
build_plugin image "libdecoration cairo-xlib" "libdecoration cairo-xlib"
